//
//  RMMSkillDetalTableViewCell.m
//  Romomo
//
//  Created by puman on 2017/2/7.
//  Copyright © 2017年 mazegong. All rights reserved.
//

#import "RMMSkillDetalTableViewCell.h"

@implementation RMMSkillDetalTableViewCell
{
    UILabel *_timeLabel;
    UILabel *_evaluationLabel;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 8, kScreenWideth - 15 - 91, kMaric)];
        _timeLabel.font = kFont(12);
        _timeLabel.textColor = COLORFROMCODE(0xBFBFBF , 1);
        [self.contentView addSubview:_timeLabel];
        
        for (int i = 0; i < 5; i++) {
            UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(kScreenWideth - 91 + 16 * i, 8, 12, 12)];
            imageV.tag = 10000 + i;
            imageV.image = [UIImage imageNamed:@"星1-2@3x"];
            [self.contentView addSubview:imageV];
        }
        
        _evaluationLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, _timeLabel.bottom, kScreenWideth - 30, kHalf - kRow)];
        _evaluationLabel.textColor = COLORFROMCODE(0x000000, 1);
        _evaluationLabel.font = kFont(14);
        _evaluationLabel.numberOfLines = 0;
        [self.contentView addSubview:_evaluationLabel];

    }
    return self;
}
- (void)setDic:(NSDictionary *)dic{
    _timeLabel.text = [RMMFileManager retrunObjWith:dic[@"CREATE_TIME"]];
    _evaluationLabel.text = [RMMFileManager retrunObjWith:dic[@"REMARK"]];
    CGRect rect = _evaluationLabel.frame;
    rect.size.height = [UILabel backHeightWithString:_evaluationLabel.text CGFloatCount:kScreenWideth - 30 metho:HEIGHT font:14];
    _evaluationLabel.frame = rect;
    [self setStarWith:[RMMFileManager retrunObjWith:dic[@"SCORE"]]];
}
- (void)setStarWith:(NSString *)score{
    NSInteger s1 = [score integerValue];
    CGFloat s2 = [score floatValue];
    for (int i = 0; i < 5; i++) {
        UIImageView *imageV = [self viewWithTag:10000 + i];
        if (i < s1) {
            imageV.image = [UIImage imageNamed:@"星-1@3x"];
        } else {
            if (i >= s1 && i < s2) {
                imageV.image = [UIImage imageNamed:@"星-3@3x"];
            } else {
                imageV.image = [UIImage imageNamed:@"星1-2@3x"];
            }
            
        }
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
